//
// Created by root on 19-7-28.
//

#include "hook_test.h"
#include "AndHook.h"
#include <android/log.h>

static jmethodID old_method=nullptr;

void my_set_text(JNIEnv *env,jobject instance,jstring text_){
    __android_log_print(ANDROID_LOG_DEBUG,"setText","set_text:%s\n",env->GetStringUTFChars(text_,nullptr));
}
void hook_test(JNIEnv *env) {
    jclass textview_class=env->FindClass("android/widget/TextView");
    AKJavaHookMethod(env,textview_class,
            "setText","(Ljava/lang/CharSequence;)V",
                     reinterpret_cast<void*>(my_set_text),&old_method);
    __android_log_print(ANDROID_LOG_DEBUG,"setText","old_method:%p\n",old_method);
}
